home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / swin_0_1.zip / STYPES.INC < prev    next >
Text File  |  1993-01-20  |  2KB  |  92 lines

  1. Unit sTypes;
  2.  
  3. Interface
  4.  
  5. Uses Graph;
  6.  
  7. Type
  8.   PChar=^Char;
  9.  
  10. Function StrDispose(sP:PChar):Byte;
  11. Procedure StrSet(P:PChar;S:String);
  12. Procedure StrPas(var S:String;P:PChar);
  13. Procedure CenterText(X1,Y1,X2,Y2:Word;Title:PChar);
  14. Function StrNew(S:String):Pointer;
  15.  
  16. Implementation
  17.  
  18. Function StrNew(S:String):Pointer;
  19.   Type
  20.     A=Array[0..255] Of Char;
  21.     Pnt=^A;
  22.   Var
  23.     P:Pnt;
  24.  
  25.   Begin
  26.     New(P);
  27.     StrSet(PChar(P),S);
  28.     StrNew:=P;
  29.   End;
  30.  
  31. Function StrDispose(sP:PChar):Byte;
  32.   Type
  33.     A=Array[0..255] Of Char;
  34.     Pnt=^A;
  35.   Var
  36.     P:Pnt;
  37.   Begin
  38.     P:=Pnt(sP);
  39.     Dispose(P);
  40.     StrDispose:=1;
  41.   End;
  42.  
  43. Procedure CenterText(X1,Y1,X2,Y2:Word;Title:PChar);
  44.   Var
  45.     Center:Word;
  46.     TitleString:String;
  47.  
  48.   Begin
  49.     SetViewPort(X1,Y1,X2,Y2,ClipOn);
  50.     Center:=(X2-X1) div 2;
  51.     StrPas(TitleString,Title);
  52.     OutTextXY(Center-TextWidth(TitleString)div 2,3,TitleString);
  53.     SetViewPort(0,0,GetMaxX,GetMaxY,ClipOn);
  54.   End;
  55.  
  56. Procedure StrPas(var S:String;P:PChar);
  57.   Var
  58.     t:Byte;
  59.     x,y:Word;
  60.  
  61.   Begin
  62.     t:=1;
  63.     While P^<>#0 Do
  64.       Begin
  65.         S[t]:=P^;
  66.         x:=Ofs(P^);
  67.         y:=Seg(P^);
  68.         Inc(x);
  69.         P:=Ptr(y,x);
  70.         inc(t);
  71.       End;
  72.     S[0]:=Chr(t-1);
  73.   End;
  74.  
  75. Procedure StrSet(P:PChar;S:String);
  76.   Var
  77.     t:Byte;
  78.     x,y:Word;
  79.  
  80.   Begin
  81.     For t:=1 to Length(S) Do
  82.       Begin
  83.         P^:=S[t];
  84.         x:=Ofs(P^);
  85.         y:=Seg(P^);
  86.         Inc(x);
  87.         P:=Ptr(y,x);
  88.       End;
  89.     P^:=#0;
  90.   End;
  91.  
  92. End.